package com.dynamic.mybatis.core.utils;

import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Map;

public class CollectionUtils extends com.baomidou.mybatisplus.core.toolkit.CollectionUtils {

    public static <T> T[] toArray(Collection<T> collection, Class<T[]> clazz) {
        return CollectionUtils.isNotEmpty(collection) ? collection.toArray((T[]) Array.newInstance(clazz.getComponentType(), collection.size())) : null;
    }

    public static boolean isNotEmpty(Object object) {
        return !isEmpty(object);
    }

    public static boolean isEmpty(Object object) {
        return object == null
        || (object instanceof Collection && ((Collection)object).isEmpty())
        || (object instanceof Map && ((Map)object).isEmpty());
    }


}
